function deleteMenuElementsActiveClass(){
    $('.nav .navbar-nav > li > a').each(function(){
        $(this).removeClass('active');
    });
}

function showLoader(message){
    $('#loader_message').text(message);
    $('#loader').css('display', 'block');
}

function hideLoader(){
    $('#loader_message').text('');
    $('#loader').css('display', 'none');
}

var services = {
    "obtener_comparaciones": "/service/comparaciones/obtenerComparaciones",
    "obtener_rastreos_sin_comparaciones": "/service/rastreos/obenerRastreosSinComparacion",
    "insertar_comparacion" : "/service/comparaciones/guardarComparacion",
    "modificar_comparacion" : "/service/comparaciones/modificarComparacion",
    "eliminar_comparacion" : "/service/comparaciones/eliminarComparacion"
};

function getServiceURL(serviceName){
    return services[serviceName];
}

function showElement(elementId){
    $(elementId).css('display', 'block');
}

function hideElement(elementId){
    $(elementId).css('display', 'none');
}

function setMessage(container, code, messageElement, message){
    switch (code){
        case 'WARN':
            $(container).removeClass('alert-danger');
            $(container).removeClass('alert-success');
            $(container).addClass('alert-warning');
            break;
        case 'ERROR':
            $(container).addClass('alert-danger');
            $(container).removeClass('alert-success');
            $(container).removeClass('alert-warning');
            break;
        case 'OK':
            $(container).removeClass('alert-danger');
            $(container).addClass('alert-success');
            $(container).removeClass('alert-warning');
            break;
    }

    $(messageElement).text(message);
}

function getStatusFromCode(estatus){
    switch(estatus){
        case 0: //ESTADO NO INICIADO
            return "CE";
            break;;
        case 1:
            return "EP"
            break;;
        case 2:
            return "NI"
            break;;
        case 3:
            return "FC";
            break;;
    }
}

function transformComparationsData(responseData){
    for (var i=0; i < responseData.length; i++){
        responseData[i].estado = getStatusFromCode(responseData[i].estado);
    }
    return responseData;
}

function callService(uriService, jsonData, onSuccess, onFail){
    $.ajax({
        type: 'POST',
        url: uriService,
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(jsonData),
        dataType: 'json',
        success: onSuccess,
        error: onFail
    });
}

function acivateModal(name, title){
    $(name + " > .modal-dialog > .modal-content > .modal-header > .modal-title").text(title);
    $(name).modal('show');
}

function cleanModal(name){
    $(name + " > .modal-dialog > .modal-content > .modal-header > .modal-title").text("");

}

function deactivateModal(name){
    $(name).modal('hide');
    cleanModal(name);
}